import React, { Component } from 'react'

export class Page extends Component {
  render() {
      const {page,pages,onchangepage,onshangyiye,onxiayiye}=this.props
    return (
      <div>
          <button disabled={page===0} onClick={()=>{
              onchangepage(0)
          }}>首页</button>
          <button disabled={page===0} onClick={onshangyiye}>上一页</button>
          {pages.length?pages.map((item,index)=>{
              return <button
              key={index}
              className={index===page?'on':''}
              onClick={()=>{
                  onchangepage(index)
              }}
              >{index+1}</button>
          }):'暂无页码'}
          <button disabled={page===pages.length-1} onClick={onxiayiye}>下一页</button>
          <button disabled={page===pages.length-1} onClick={()=>{
              onchangepage(pages.length-1)
          }}>尾页</button>
      </div>
    )
  }
}

export default Page